<template>
    <div>
      <h3>组件B</h3>
      <button @click="send">发送消息</button>
    </div>
  </template>
  
  <script>
  // @ --> 指向着当前项目的src目录
  import Bus from '@/utils/EventBus';
  
  // 发送方
  export default {
    data() {
      return {
        dog: {
          name: '旺财',
          age: 10
        }
      }
    },
    methods: {
      send() {
        Bus.$emit('sendMsg', this.dog)
      }
    },
  }
  </script>
  
  <style scoped></style>